import { makeAutoObservable } from 'mobx';
import { inject, injectable } from 'inversify';
import { RoomModel } from '../models/room.model.ts';
import { ROOM_MODE } from '../models/enum.ts';
import { WebRTC } from '@todo/core';

@injectable()
export class RoomViewModel {
  get loading() {
    return this.roomModel.loading;
  }

  get mode() {
    return this.roomModel.mode;
  }

  get noteView() {
    return this.roomModel.noteView;
  }

  get peerId() {
    return this.webRTC.apeer.id;
  }

  constructor(
    @inject(RoomModel)
    private roomModel: RoomModel,
    @inject('WebRTC')
    private webRTC: WebRTC,
  ) {
    makeAutoObservable(this);
  }

  connect(id: string) {
    this.webRTC.connect(id);
  }

  send(data: any) {
    this.webRTC.send(data);
  }

  setMode(mode: ROOM_MODE) {
    this.roomModel.mode = mode;
  }

  setNoteView() {
    this.roomModel.setNoteView();
  }

  dispose() {
    this.roomModel.dispose();
  }
}
